package lesson3.api;

import java.util.concurrent.TimeUnit;

import lesson3.api.helpers.LocatorHelper;
import lesson3.api.helpers.NavigationHelper;
import lesson3.api.helpers.PageHelper;
import lesson3.api.helpers.WebElementHelper;

import org.openqa.selenium.firefox.FirefoxDriver;

public class ApplicationManager
{
	// Site URL
	public final static String SITE_URL = "https://redmine.cupidplc.com";
	// Test page
	public String testPage;
	// Web drivers
	public FirefoxDriver driver;
	// Page helpers
	private PageHelper pageHelper;
	private NavigationHelper navigationHelper;
	private WebElementHelper webElementHelper;
	private LocatorHelper locatorHelper;

	public ApplicationManager()
	{

	}

	public void init()
	{
		// Create a driver
		driver = new FirefoxDriver();
		driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
	}

	public void stop()
	{
		// Stop a driver
		driver.quit();
	}

	public PageHelper page()
	{
		if (pageHelper == null)
		{
			pageHelper = new PageHelper(this);
		}
		return pageHelper;
	}

	public NavigationHelper navigation()
	{
		if (navigationHelper == null)
		{
			navigationHelper = new NavigationHelper(this);
		}
		return navigationHelper;
	}

	public WebElementHelper webElement()
	{
		if (webElementHelper == null)
		{
			webElementHelper = new WebElementHelper(this);
		}
		return webElementHelper;
	}

	public LocatorHelper locator()
	{
		if (locatorHelper == null)
		{
			locatorHelper = new LocatorHelper(this);
		}
		return locatorHelper;
	}

}
